package com.cm.stock.manager.service;

import com.cm.stock.manager.dao.ClientDAO;
import com.cm.stock.manager.dto.ClientDTO;

public class ClientService {
	
	private ClientDAO clientDAO;
	
	public ClientDTO getClientByCode (String code){
		return clientDAO.getByCode(code);
	}
	
	public ClientDTO saveClient (String lastName, String firstName, String phone1, String phone2, String ville){
		String code = clientDAO.getMaxId()+"";
		return clientDAO.save(new ClientDTO(code, lastName, firstName, phone1, phone2, ville));
	}
	
	public ClientDTO updateClient (ClientDTO client){
		return clientDAO.update(client);
	}
	
	public void deleteClient (Integer id) throws Exception{
		clientDAO.deleteOne(id);	
	}

	public void setClientDAO(ClientDAO clientDAO) {
		this.clientDAO = clientDAO;
	}
	

}
